package chapter9.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Window;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class RPCTutorial implements EntryPoint {
	public void onModuleLoad() {

		
		RequestBuilder req = new RequestBuilder (RequestBuilder.GET, "http://g.cn");
		try {
			req.sendRequest(null, new RequestCallback(){
				@Override
				public void onError(Request request, Throwable exception) {
				}

				@Override
				public void onResponseReceived(Request request, Response response) {
					Window.alert(response.getText());
				}
			});
		} catch (RequestException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
